#31-拷贝文件
# src_fname = '/tmp/ls'
# dst_fname = '/root/ls'
# src_fobj = open(src_fname, 'rb')
# dst_fobj = open(dst_fname, 'wb')
# while True:
#     data = src_fobj.read(4096)
#     if not data :
#         break
#     dst_fobj.write(data)
# src_fobj.close()
# dst_fobj.close()
#32-位置参数
# import sys
# print(sys.argv)
#33-函数应用-斐波那契数列
# fib = [0, 1]
# for i in range(8):
#     fib.append(fib[-2] + fib[-1])
# print(fib)
#34-函数-拷贝文件
# import sys
# def copy(src_fname,dst_fname):
#     src_fobj = open(src_fname,'rb')
#     dst_fobj = open(dst_fname,'wb')
#     while 1:
#         data = src_fobj.read(4096)
#         if not data:
#             break
#         dst_fobj.write(data)
#     src_fobj.close()
#     dst_fobj.close()
# copy(sys.argv[1],sys.argv[2])
#35-函数-九九乘法表
# def mtable(m):
#     for i in range(1, m + 1):
#         for n in range(1, i+1):
#             print('%sX%s=%s ' % (i, n, i * n),end='\t')
#         print('')
# mtable(6)
# mtable(9)
#36-模块基础
# hi = 'hello world'
# def pstar(n=50):
#     print('*' * n)
# if __name__ == '__main__':
#     pstar()
#     pstar(30)
#37-生成密码/验证码
# from random import choice
# import string
# all_chs= string.ascii_letters+string.digits
#
# def gen_pass(n=8):
#     result= ''
#     for i in range(10):
#         ch = choice(all_chs)
#         result += ch
#     return result
# if __name__ == '__main__':
#     print(gen_pass())
#     print(gen_pass(4))
#     print(gen_pass(8))
#38-序列对象方法
from random import randint
# alist = list()
# list('list')
# list((10, 20, 30))
# #39-序列对象方法2
# alist= [10, 'john']
# alist
# [10, 'john']
# len(alist)
# list(enumerate(alist))
# [(0, 10), (1, 'john')]
# for ind in range(len(alist)):
#     print('%s: %s ' % (ind, alist[ind]))
# for item in enumerate(alist):
#     print('%s: %s'% (item[0],item[1]))
# for ind,val in enumerate(alist):
#     print('%s: %s' % (ind, val))
40-字符串方法
py_str = 'hello world'
py_str
'hello world'
py_str.capitalize()
'Hello world'
py_str.title()
'Hello World'
py_str.center(50)
'                   hello world                    '
py_str.center(50, '#')
'###################hello world####################'
py_str.ljust(50,'*')
'hello world***************************************'
py_str.rjust(50,'*')
'***************************************hello world'
py_str.count('1')
0
py_str.count('lo')
1
py_str.endswith('!')
False
py_str.startswith('a')
False
py_str.startswith('h')
True
py_str.islower()
True
py_str.isupper()
False
py_str.isalnum()
False
>>> '     hello\t   '.strip()
'hello'
>>> '     hello\t   '.lstrip()
'hello\t   '
>>> '     hello\t   '.rstrip()
'     hello'
>>> 'how are you'.split()  #切分
['how', 'are', 'you']
>>> 'hello.tar.gz'.split('.')  #以.分割
['hello', 'tar', 'gz']
>>> '.'.join(['hello', 'tar', 'gz'])   #聚合字符串
'hello.tar.gz'
>>> '-'.join(['hello', 'tar', 'gz'])       #以-间距聚合
'hello-tar-gz'